package com.vcourse.service.edu.controller.api;

import com.vcourse.commons.result.R;
import com.vcourse.service.edu.entity.Course;
import com.vcourse.service.edu.entity.Teacher;
import com.vcourse.service.edu.service.CourseService;
import com.vcourse.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Zengsh123
 * @date 2020-06-07 20:54
 */
@Api("首页")
@RestController
@RequestMapping("/api/edu/index")
public class ApiIndexController {

    @Resource
    private CourseService courseService;

    @Resource
    private TeacherService teacherService;

    @ApiOperation("课程列表")
    @GetMapping
    public R index(){

        //获取首页最热门前8条课程数据
        List<Course> courseList = courseService.selectHotCourse();
        //获取首页推荐前4条讲师数据
        List<Teacher> teacherList = teacherService.selectHotTeacher();
        Map<String, Object> map = new HashMap<>(2);
        map.put("courseList", courseList);
        map.put("teacherList", teacherList);
        return R.ok().data(map);
    }
}